<div class="SipeiMain_r fr">
    <h2 class="clearfix fonts_18 height45 fontc_444"><?php echo $this->title; ?></h2>
    <?php
    $form = $this->beginWidget('CActiveForm', array(
    'action' => Yii::app()->createUrl($this->route),
    'method' => 'GET',
    'id' => 'searchForm'
    ));
    ?>
    <div class="clearfix back_bgf border_3 border_c pr30 pt20 pb20 height32 fontc_666">
        <table with="100%">
            <tbody>
                <tr>
                    <td width="150" align="right" class="pt10 pr2">所属考试项目：</td>
                    <td width="245" class="pt10">
                        <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                            <span class="fl select_shelter">
                                <select class="fl fontc_666" name="exam_id">
                                    <option value="0">请选择</option>
                                    <?php if ($date['examall']): foreach ($date['examall'] as $one): ?>
                                            <option value="<?php echo $one['exam_id']; ?>" <?php if($date['exam_id'] == $one['exam_id']):?> selected <?php endif;?>><?php echo $one['exam_term_name'];?>
                                            </option>
                                    <?php endforeach; endif;?>
                                </select>
                            </span>
                        </span>
                    </td>
                    <td width="140" align="right" class="pt10 pr2">所属科目：</td>
                    <td width="150" class="pt10">
                        <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                            <span class="fl select_shelter select_shelter2">
                                <select class="fl fontc_666" name="subject_id">
                                    <option value="0">请选择</option>
                                    <?php if ($date['subjectall']): foreach ($date['subjectall'] as $one): ?>
                                            <option value="<?php echo $one['subject_id']; ?>" <?php if($date['subject_id'] == $one['subject_id']) {echo "selected";} ?>><?php echo $one['subject_name']; ?>
                                            </option>
                                    <?php endforeach;endif;?>
                                </select>
                            </span>
                        </span>
                    </td>
                    <td align="right" width="120" class="pt15"><input type="submit" value="查询" class="b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor" /></td>
                </tr>
            </tbody>
        </table>
    </div>
    <?php
    $this->endWidget();
    ?>
    <div class="clearfix back_bgf border_c mt15 pt20 pb20">
    	<div class="clearfix pb20 pl30">
            <input type="button" value="新增" onclick="add();" style="margin-right:30px;" class="fr b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor" />
        </div>
        <form>
            <table class="height40" width="100%">
                <thead class="back_bgf5 fontc_666">
                    <tr>
                        <th width="194" align="center" class="m_hr_t m_hr_b pl10">考试项目</th>
                        <th width="94" align="center" class="m_hr_t m_hr_b">科目</th>
                        <th width="90" align="center" class="m_hr_t m_hr_b">汇总栏位</th>
                        <th width="90" align="left" class="m_hr_t m_hr_b">汇总方式</th>
                        <th width="220" align="left" class="m_hr_t m_hr_b pl10">汇总详细</th>
                        <th width="90" align="center" class="m_hr_t m_hr_b">操作</th>
                    </tr>
                </thead>
                <tbody class="fontc_444">
                    <?php if ($data): foreach ($data as $one): ?>
                	<tr>
	                    <td align="center" class="m_hr_b fontc_666 pl10"><?php $exam_ary= ZTask::_getExamAll(' AND "exam_id" = '.$one['exam_id']); if (!empty($exam_ary)){echo $exam_ary[0]['exam_term_name'];}?></td>
	                    <td align="center" class="m_hr_b"><?php $subject = ExamData::_getSubject($one['subject_id']);if (!empty($subject)){ echo $subject['subject_name'];}?></td>
	                    <td align="center" class="m_hr_b">
	                    <?php
	                    	if (isset($qdata[$one['collect_fields']])):
	                    		echo $qdata[$one['collect_fields']];
	                    	endif; ?>
	                    </td>
	                    <td align="left" class="m_hr_b">
	                    	<?php $mode = ZTask::_getcollect_mode(); if (!empty($mode)){echo $mode[$one['collect_mode']];}?>
	                    </td>
	                    <?php if($one['collect_mode']==1):?>
	                    <td align="left" class="m_hr_b height20 pt5 pb5 pl10">
	                    <?php 
	                    $subjecttype = SmallProblem::_getQuestionInfo($one['collect_questions']); 
	                    echo $subjecttype; ?></td>
	                    <?php else:?>
	                    <td align="left" class="m_hr_b height20 pt5 pb5 pl10">
	                    <?php 
	                    	$where = ' AND "id" IN('.$one['collect_question'].')'; 
	                    	$subjectquestion = SmallProblem::_getquestion_num($where);
	                    	$nums = array();
	                    	foreach ($subjectquestion as $k=>$v){
	                    		$nums[]= $v['num_id'];
	                    	} 
	                    	echo implode('；',$nums); ?></td>
	                    <?php endif;?>
	                    <td align="center" class="m_hr_b">
	                    	<a onclick="update(<?php echo $one['id'];?>, $(this))" class="mr10 cursor"><img src="/themes/default/images/Sipei/edit.png" title="编辑" /></a>
	                        <a onclick="deleteqt(<?php echo $one['id'];?>, $(this))"><img src="/themes/default/images/Sipei/delate.png" title="删除" class="cursor" /></a>
	                   	</td>
                   	</tr>
                    <?php endforeach; else: ?>
                    <tr>
                    	<td colspan='6' align="center" class="pl30">当前没有您要的数据存在!</td>
                   	</tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </form>
        <?php $this->renderPartial('//partial/partial_pager', array('pages' => $pages, "url" => $pageUrl)); ?>
    </div>
</div>

<script type="text/javascript" >
var api;
function deleteqt(id, $this) {
	$.dialog.confirm('确定删除吗', function() {
		if(id!=''){
			location.href="<?php echo $this->createUrl("/question_collect/default/delete")?>/id/"+id;
		}else{
			alert('id不能为空');
		}
	});
}
function update(id, $this){
	api = $.dialog({
		id: 'testID2',
		lock: true,
		fixed: true,
		title: "编辑",
		width: 500,
		height: 380,
		max: false,
		min: false
	});
	$.get('/question_collect/default/update',{id:id}, function(data){
		api.content(data);
	});
}
function add() {
	api = $.dialog({
		id: 'testID2',
		lock: true,
		padding:0,
		fixed: true,
		title:"新增",
		width:480,
		height:530,
		max: false,
		min: false
	});
	$.get('/question_collect/default/add',function(html){
		api.content(html);
	});
}
$(function() {
	$(".checkboxs").click(function() {
		var checkedS = $(this).attr("checked");
		if (checkedS) {
			$(".checkbox").attr("checked", true)
		} else {
			$(".checkbox").removeAttr("checked")
		}
	})

})
</script>